PROJECT(alicloud_httpdns_c_sdk_test LANGUAGES C)

##################################### Unit test Application ##########################################
INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${APU_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${APR_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${CJSON_INCLUDE_DIR})
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/src" "${CMAKE_SOURCE_DIR}/tests")
AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR}/tests TEST_SRC_LIST)
AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR}/src SDK_SRC_LIST)

SET(TEST_BIN_NAME hdns_test)

ADD_EXECUTABLE(${TEST_BIN_NAME} ${TEST_SRC_LIST} ${SDK_SRC_LIST})
TARGET_LINK_LIBRARIES(${TEST_BIN_NAME} PRIVATE ${CURL_LIBRARIES} ${CJSON_LIBRARIES} ${APU_LIBRARIES} ${APR_LIBRARIES})
IF (CMAKE_HOST_UNIX AND NOT CMAKE_HOST_APPLE)
    TARGET_LINK_LIBRARIES(${TEST_BIN_NAME} PRIVATE dl)
ENDIF ()

## 这里没有使用原生的CTest，而是使用CuTest框架
ADD_CUSTOM_TARGET(hdns_unite_test
        COMMAND ${TEST_BIN_NAME}
        DEPENDS ${TEST_BIN_NAME}
        WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
        COMMENT "Running the test executable..."
)


